package com.cityeye.dao;

import org.hibernate.criterion.Order;

import com.cityeye.entity.Issuetype;
import com.cityeye.entity.Subissuetype;
import com.cityeye.search.SearchCriteria;

public class SubissuetypeDao extends AbstractEntityDao<Subissuetype>{

	private static SearchCriteria[] criteria;
	
	protected Object evalueateProperty(String key, Object valueObj){
		String idStr = valueObj.toString();
		
		if(key.equalsIgnoreCase("issuetype")){
			return sf.getCurrentSession().get(Issuetype.class,Integer.parseInt(idStr));
		}
		
		return valueObj;
	}	
	
	public Subissuetype createNewEmptyEntity() {
		return new Subissuetype();
	}

	public SearchCriteria[] getSearchCriteria() {
		if (criteria == null) {
			criteria = new SearchCriteria[] {
					new SearchCriteria("Code", SearchCriteria.VT_INT),
					new SearchCriteria("Name", SearchCriteria.VT_STRING),
					new SearchCriteria("Taxable", SearchCriteria.VT_STRING),
					new SearchCriteria("Mobile", SearchCriteria.VT_STRING) };
		}
		return criteria;
	}

	
	protected Class<Subissuetype> getEntityClass(){
		return Subissuetype.class;
	}
	
	protected Order getOrderField(){
		return Order.asc("name");
	}	
}
